class Solution {
public:
    int maxArea(vector<int>& height)
    {
        int right = height.size() - 1;
        int left = 0;

        int maxV = 0;
        while (right != left)
        {
            int h = height[right] > height[left] ? height[left] : height[right];
            int w = right - left;

            int V = h * w;
            if (V > maxV)
                maxV = V;

            if (height[right] >= height[left])
            {
                left++;
            }
            else
            {
                right--;
            }
        }

        return maxV;
    }
};